#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>

using namespace std;

class Solution {
public:
    int halveArray(vector<int>& nums) {
        double sum = 0;
        priority_queue<double> head;

        for (auto e : nums) {
            head.push(e);
            sum += e;
        }
        double count = sum;
        int n = 0;

        while (count > sum / 2) {
            head.push(head.top() / 2);
            count -= head.top() / 2;
            head.pop();
            n++;
        }
        return n;
    }
}; 
class Solution {
public:
    int halveArray(vector<int>& nums) {
        double sum = 0;
        priority_queue<double> head;

        for (auto e : nums) {
            head.push(e);
            sum += e;
        }
        double count = sum;
        int n = 0;

        while (count > sum / 2) {
            head.push(head.top() / 2);
            count -= head.top() / 2;
            head.pop();
            n++;
        }
        return n;
    }
};